import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.core.IsNot.not;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Alert;
import org.openqa.selenium.Keys;
import java.util.*;
import java.net.MalformedURLException;
import java.net.URL;
public class PSYCounselRecordAdminTest {
  private WebDriver driver;
  private Map<String, Object> vars;
  JavascriptExecutor js;
  @Before
  public void setUp() {
    driver = new ChromeDriver();
    js = (JavascriptExecutor) driver;
    vars = new HashMap<String, Object>();
  }
  @After
  public void tearDown() {
    driver.quit();
  }
  public void PSYLoginAdminTrue01() {
    driver.get("https://sei-test.021hqit.com/group-5/group-5/");
    driver.findElement(By.cssSelector(".el-form-item:nth-child(1) .el-input__inner")).sendKeys("ecnu_admin");
    driver.findElement(By.cssSelector(".el-form-item:nth-child(2) .el-input__inner")).click();
    driver.findElement(By.cssSelector(".el-form-item:nth-child(2) .el-input__inner")).sendKeys("pl,okm123");
    driver.findElement(By.cssSelector(".el-button")).click();
    vars.put("message", driver.findElement(By.cssSelector(".el-message")).getText());
    assertEquals(vars.get("message").toString(), "登录成功");
  }
  @Test
  public void pSYCounselRecordAdminBulkExport() {
    PSYLoginAdminTrue01();
    driver.findElement(By.cssSelector(".el-menu-item:nth-child(2) > span")).click();
    driver.findElement(By.cssSelector(".el-table__row:nth-child(1) .el-checkbox__inner")).click();
    driver.findElement(By.cssSelector(".el-table__row:nth-child(2) .el-checkbox__inner")).click();
    driver.findElement(By.cssSelector(".el-table__row:nth-child(3) .el-checkbox__inner")).click();
    driver.findElement(By.cssSelector(".customButton")).click();
    driver.findElement(By.cssSelector(".el-button--small:nth-child(2)")).click();
    {
      WebElement element = driver.findElement(By.cssSelector(".el-button--small:nth-child(2)"));
      Actions builder = new Actions(driver);
      builder.moveToElement(element).perform();
    }
    {
      WebElement element = driver.findElement(By.tagName("body"));
      Actions builder = new Actions(driver);
      builder.moveToElement(element, 0, 0).perform();
    }
  }
  @Test
  public void pSYCounselRecordAdminDetail() {
    PSYLoginAdminTrue01();
    driver.findElement(By.cssSelector(".el-menu-item:nth-child(2) > span")).click();
    driver.findElement(By.cssSelector(".el-table__row:nth-child(1) .el-button:nth-child(1) > span")).click();
  }
  @Test
  public void pSYCounselRecordAdminExport() {
    PSYLoginAdminTrue01();
    driver.findElement(By.cssSelector(".el-menu-item:nth-child(2) > span")).click();
    driver.findElement(By.cssSelector(".el-table__row:nth-child(1) .el-button:nth-child(2)")).click();
    driver.findElement(By.cssSelector(".el-button--small:nth-child(2) > span")).click();
  }
  @Test
  public void pSYCounselRecordAdminSearchByName() {
    PSYLoginAdminTrue01();
    driver.findElement(By.cssSelector(".el-menu-item:nth-child(2) > span")).click();
    driver.findElement(By.cssSelector(".searchItem:nth-child(1) .el-input__inner")).click();
    driver.findElement(By.cssSelector(".searchItem:nth-child(1) .el-input__inner")).sendKeys("吴文轩\\n");
  }
  @Test
  public void pSYCounselRecordAdminDetailExport() {
    PSYLoginAdminTrue01();
    driver.findElement(By.cssSelector(".el-menu-item:nth-child(2) > span")).click();
    driver.findElement(By.cssSelector(".el-table__row:nth-child(1) .el-button:nth-child(1) > span")).click();
    driver.findElement(By.cssSelector(".btns > div:nth-child(1) > img")).click();
    driver.findElement(By.cssSelector(".el-button--default:nth-child(2) > span")).click();
  }
  @Test
  public void pSYCounselRecordAdminSearchByCounselor() {
    PSYLoginAdminTrue01();
    driver.findElement(By.cssSelector(".el-menu-item:nth-child(2) > span")).click();
    driver.findElement(By.cssSelector(".searchItem:nth-child(2) .el-input__inner")).click();
    driver.findElement(By.cssSelector(".searchItem:nth-child(2) .el-input__inner")).sendKeys("ao\\n");
  }
  @Test
  public void pSYCounselRecordAdminSearchByDate() {
    PSYLoginAdminTrue01();
    driver.findElement(By.cssSelector(".el-menu-item:nth-child(2) > span")).click();
    driver.findElement(By.cssSelector(".el-range-input:nth-child(2)")).click();
    driver.findElement(By.cssSelector(".is-left .el-date-table__row:nth-child(2) > .available:nth-child(6) span")).click();
    driver.findElement(By.cssSelector(".is-left .el-date-table__row:nth-child(5) > .available:nth-child(1) span")).click();
    driver.findElement(By.cssSelector(".is-plain > span")).click();
  }
  @Test
  public void pSYCounselRecordAdminSearchByAll() {
    PSYLoginAdminTrue01();
    driver.findElement(By.cssSelector(".el-menu-item:nth-child(2) > span")).click();
    driver.findElement(By.cssSelector(".searchItem:nth-child(1) .el-input__inner")).click();
    driver.findElement(By.cssSelector(".searchItem:nth-child(1) .el-input__inner")).sendKeys("王雨晨");
    driver.findElement(By.cssSelector(".searchItem:nth-child(2) .el-input__inner")).click();
    driver.findElement(By.cssSelector(".searchItem:nth-child(2) .el-input__inner")).sendKeys("Kenn");
    driver.findElement(By.cssSelector(".el-range-input:nth-child(2)")).click();
    driver.findElement(By.cssSelector(".is-left .el-date-table__row:nth-child(2) > .available:nth-child(6) span")).click();
    driver.findElement(By.cssSelector(".is-left .el-date-table__row:nth-child(5) > .available:nth-child(3) span")).click();
    driver.findElement(By.cssSelector(".is-plain > span")).click();
  }
}
